<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>docker | 兜里有糖</title><meta name="keywords" content="编程"><meta name="author" content="兜里有糖"><meta name="copyright" content="兜里有糖"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="这几天学了一下docker的相关知识，记录一下 安装官网有教程 卸载旧版本12345678sudo yum remove docker \                docker-client \                docker-client-latest \                docker-common \                docker-latest \">
<meta property="og:type" content="article">
<meta property="og:title" content="docker">
<meta property="og:url" content="https://blog.cwxhmk.top/2021/05/08/program/2021-05-08-docker/index.html">
<meta property="og:site_name" content="兜里有糖">
<meta property="og:description" content="这几天学了一下docker的相关知识，记录一下 安装官网有教程 卸载旧版本12345678sudo yum remove docker \                docker-client \                docker-client-latest \                docker-common \                docker-latest \">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://image.cwxhmk.top/blog/docker.jpg">
<meta property="article:published_time" content="2021-05-08T20:16:19.000Z">
<meta property="article:modified_time" content="2022-01-04T18:31:04.998Z">
<meta property="article:author" content="兜里有糖">
<meta property="article:tag" content="编程">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://image.cwxhmk.top/blog/docker.jpg"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://blog.cwxhmk.top/2021/05/08/program/2021-05-08-docker/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//hm.baidu.com"/><link rel="preconnect" href="//fonts.googleapis.com" crossorigin=""/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?a14889b83a055b58cc3b9baac0e8d397";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Titillium+Web&amp;display=swap" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: true,
    post: true
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'docker',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-01-04 18:31:04'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    })(window)</script><meta name="baidu-site-verification" content="code-DLRo0M1JYB" /><meta name="msvalidate.01" content="68CBEB31DECE622B51F762A579742691" /><meta name="google-site-verification" content="EbiglcFzq1VMWmp5uIo4rPO8dnEVWbr06jCFe_BGHfo" /><link rel="stylesheet" href="/css/person.css"><meta name="generator" content="Hexo 5.1.1"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" src= "/img/loading.gif" data-lazy-src="https://image.cwxhmk.top/blog/tou.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">14</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">11</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">1</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间线</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 列表</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/Gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://image.cwxhmk.top/blog/docker.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">兜里有糖</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间线</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 列表</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/Gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">docker</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-05-08T20:16:19.000Z" title="发表于 2021-05-08 20:16:19">2021-05-08</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-01-04T18:31:04.998Z" title="更新于 2022-01-04 18:31:04">2022-01-04</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E7%BC%96%E7%A8%8B/">编程</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">2.6k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>9分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="docker"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span><span class="post-meta-separator">|</span><span class="post-meta-commentcount"><i class="far fa-comments fa-fw post-meta-icon"></i><span class="post-meta-label">评论数:</span><a href="/2021/05/08/program/2021-05-08-docker/#post-comment"><span class="waline-comment-count" id="/2021/05/08/program/2021-05-08-docker/"></span></a></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><p>这几天学了一下docker的相关知识，记录一下</p>
<h2 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h2><p>官网有<a target="_blank" rel="noopener" href="https://docs.docker.com/engine/install/centos/">教程</a></p>
<h3 id="卸载旧版本"><a href="#卸载旧版本" class="headerlink" title="卸载旧版本"></a>卸载旧版本</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">sudo yum remove docker \</span><br><span class="line">                docker-client \</span><br><span class="line">                docker-client-latest \</span><br><span class="line">                docker-common \</span><br><span class="line">                docker-latest \</span><br><span class="line">                docker-latest-logrotate \</span><br><span class="line">                docker-logrotate \</span><br><span class="line">                docker-engine</span><br></pre></td></tr></table></figure>

<h3 id="安装新版本"><a href="#安装新版本" class="headerlink" title="安装新版本"></a>安装新版本</h3><p>需要centos7版本以上的</p>
<p>安装一些必要的系统工具:</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo yum install -y yum-utils device-mapper-persistent-data lvm2</span><br></pre></td></tr></table></figure>
<p>添加软件源信息：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo</span><br></pre></td></tr></table></figure>
<p>安装 Docker-ce：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo yum install -y docker-ce</span><br></pre></td></tr></table></figure>
<p>启动 Docker 后台服务:</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl start docker</span><br><span class="line">sudo systemctl enable docker</span><br></pre></td></tr></table></figure>

<h3 id="Docker镜像加速"><a href="#Docker镜像加速" class="headerlink" title="Docker镜像加速"></a>Docker镜像加速</h3><p>在拉取Docker镜像时如果未指明镜像地址则默认从docker-hub上拉取，国内访问docker-hub的速度较慢，所以需要将docker源更改为国内的源。<br>配置/etc/docker/daemon.json即可，我使用的是阿里云的源：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">sudo mkdir -p /etc/docker</span><br><span class="line">sudo tee /etc/docker/daemon.json &lt;&lt;-&#x27;EOF&#x27;</span><br><span class="line">&#123;</span><br><span class="line">  &quot;registry-mirrors&quot;: [&quot;https://w76qpozk.mirror.aliyuncs.com&quot;]</span><br><span class="line">&#125;</span><br><span class="line">EOF</span><br></pre></td></tr></table></figure>

<p>保存配置后需要重启服务：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl daemon-reload</span><br><span class="line">sudo systemctl restart docker</span><br></pre></td></tr></table></figure>
<h2 id="相关命令"><a href="#相关命令" class="headerlink" title="相关命令"></a>相关命令</h2><ul>
<li><p>查看容器</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> 查看运行中的容器</span></span><br><span class="line">docker ps </span><br><span class="line"><span class="meta">#</span><span class="bash"> 查看所有容器</span></span><br><span class="line">docker ps -a</span><br></pre></td></tr></table></figure>
</li>
<li><p>删除镜像</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker rm 容器id</span><br></pre></td></tr></table></figure></li>
<li><p>查看镜像</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker images</span><br></pre></td></tr></table></figure></li>
<li><p>删除镜像</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker rmi 镜像id</span><br></pre></td></tr></table></figure></li>
<li><p>进入容器内部   </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker exec -it 容器id /bin/bash</span><br></pre></td></tr></table></figure></li>
<li><p>构建Dockerfile</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker build -t runoob/ubuntu:v1 . </span><br></pre></td></tr></table></figure>
<h2 id="Dockerfile"><a href="#Dockerfile" class="headerlink" title="Dockerfile"></a>Dockerfile</h2><p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/panwenbin-logs/p/8007348.html">原文</a></p>
<h3 id="Dockerfile的基本结构"><a href="#Dockerfile的基本结构" class="headerlink" title="Dockerfile的基本结构"></a>Dockerfile的基本结构</h3><p>Dockerfile 一般分为四部分：基础镜像信息、维护者信息、镜像操作指令和容器启动时执行指令，”#” 为 Dockerfile 中的注释。</p>
</li>
</ul>
<h3 id="文件说明"><a href="#文件说明" class="headerlink" title="文件说明"></a>文件说明</h3><ul>
<li><h4 id="FROM：指定基础镜像，必须为第一个命令"><a href="#FROM：指定基础镜像，必须为第一个命令" class="headerlink" title="FROM：指定基础镜像，必须为第一个命令"></a>FROM：指定基础镜像，必须为第一个命令</h4><p>指定基础镜像，必须为第一个命令</p>
<figure class="highlight docker"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#格式：</span></span><br><span class="line">    <span class="keyword">FROM</span> &lt;image&gt;</span><br><span class="line">    <span class="keyword">FROM</span> &lt;image&gt;:&lt;tag&gt;</span><br><span class="line">    <span class="keyword">FROM</span> &lt;image&gt;@&lt;digest&gt;</span><br><span class="line"><span class="comment">#示例：　　</span></span><br><span class="line">    <span class="keyword">FROM</span> mysql:<span class="number">5.6</span></span><br><span class="line">    <span class="comment"># 注:tag或digest是可选的，如果不使用这两个值时，会使用latest版本的基础镜像</span></span><br></pre></td></tr></table></figure></li>
<li><h4 id="MAINTAINER-维护者信息"><a href="#MAINTAINER-维护者信息" class="headerlink" title="MAINTAINER: 维护者信息"></a>MAINTAINER: 维护者信息</h4><figure class="highlight docker"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#格式：</span></span><br><span class="line">    <span class="keyword">MAINTAINER</span> name&lt;email address&gt;</span><br><span class="line"><span class="comment">#示例：</span></span><br><span class="line">    <span class="keyword">MAINTAINER</span> DLYT&lt;xxx@<span class="number">163</span>.com&gt;</span><br></pre></td></tr></table></figure>
</li>
<li><h4 id="RUN：构建镜像时执行的命令"><a href="#RUN：构建镜像时执行的命令" class="headerlink" title="RUN：构建镜像时执行的命令"></a>RUN：构建镜像时执行的命令</h4><figure class="highlight docker"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#RUN用于在镜像容器中执行命令，其有以下两种命令执行方式：</span></span><br><span class="line"><span class="comment">#shell执行</span></span><br><span class="line"><span class="comment">#格式：</span></span><br><span class="line">    <span class="keyword">RUN</span><span class="bash"> &lt;<span class="built_in">command</span>&gt;</span></span><br><span class="line"><span class="comment">#exec执行</span></span><br><span class="line"><span class="comment">#格式：</span></span><br><span class="line">    <span class="keyword">RUN</span><span class="bash"> [<span class="string">&quot;executable&quot;</span>, <span class="string">&quot;param1&quot;</span>, <span class="string">&quot;param2&quot;</span>]</span></span><br><span class="line"><span class="comment">#示例：</span></span><br><span class="line">    <span class="keyword">RUN</span><span class="bash"> [<span class="string">&quot;executable&quot;</span>, <span class="string">&quot;param1&quot;</span>, <span class="string">&quot;param2&quot;</span>]</span></span><br><span class="line">    <span class="keyword">RUN</span><span class="bash"> apk update</span></span><br><span class="line">    <span class="keyword">RUN</span><span class="bash"> [<span class="string">&quot;/etc/execfile&quot;</span>, <span class="string">&quot;arg1&quot;</span>, <span class="string">&quot;arg1&quot;</span>]</span></span><br><span class="line"><span class="comment">#注RUN指令创建的中间镜像会被缓存，并会在下次构建中使用。如果不想使用这些缓存镜像，可以在构建时指定--no-cache参数，如：docker build --no-cache</span></span><br></pre></td></tr></table></figure>
</li>
<li><h4 id="ADD：将本地文件添加到容器中，tar类型文件会自动解压-网络压缩资源不会被解压-，可以访问网络资源，类似wget"><a href="#ADD：将本地文件添加到容器中，tar类型文件会自动解压-网络压缩资源不会被解压-，可以访问网络资源，类似wget" class="headerlink" title="ADD：将本地文件添加到容器中，tar类型文件会自动解压(网络压缩资源不会被解压)，可以访问网络资源，类似wget"></a>ADD：将本地文件添加到容器中，tar类型文件会自动解压(网络压缩资源不会被解压)，可以访问网络资源，类似wget</h4><figure class="highlight docker"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#格式：</span></span><br><span class="line">    <span class="keyword">ADD</span><span class="bash"> &lt;src&gt;... &lt;dest&gt;</span></span><br><span class="line">    <span class="keyword">ADD</span><span class="bash"> [<span class="string">&quot;&lt;src&gt;&quot;</span>,... <span class="string">&quot;&lt;dest&gt;&quot;</span>] <span class="comment">#用于支持包含空格的路径</span></span></span><br><span class="line"><span class="comment">#示例:</span></span><br><span class="line">    <span class="comment"># 添加所有以&quot;hom&quot;开头的文件</span></span><br><span class="line">    <span class="keyword">ADD</span><span class="bash"> hom* /mydir/  </span></span><br><span class="line">    <span class="comment"># ? 替代一个单字符,例如：&quot;home.txt&quot;        </span></span><br><span class="line">    <span class="keyword">ADD</span><span class="bash"> hom?.txt /mydir/      </span></span><br><span class="line">    <span class="comment"># 添加 &quot;test&quot; 到 `WORKDIR`/relativeDir/</span></span><br><span class="line">    <span class="keyword">ADD</span><span class="bash"> <span class="built_in">test</span> relativeDir/ </span></span><br><span class="line">    <span class="comment"># 添加 &quot;test&quot; 到 /absoluteDir/    </span></span><br><span class="line">    <span class="keyword">ADD</span><span class="bash"> <span class="built_in">test</span> /absoluteDir/    </span></span><br></pre></td></tr></table></figure></li>
<li><h4 id="COPY：功能类似ADD，但是是不会自动解压文件，也不能访问网络资源"><a href="#COPY：功能类似ADD，但是是不会自动解压文件，也不能访问网络资源" class="headerlink" title="COPY：功能类似ADD，但是是不会自动解压文件，也不能访问网络资源"></a>COPY：功能类似ADD，但是是不会自动解压文件，也不能访问网络资源</h4></li>
<li><h4 id="CMD：构建容器后调用，也就是在容器启动时才进行调用"><a href="#CMD：构建容器后调用，也就是在容器启动时才进行调用" class="headerlink" title="CMD：构建容器后调用，也就是在容器启动时才进行调用"></a>CMD：构建容器后调用，也就是在容器启动时才进行调用</h4><figure class="highlight docker"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 格式：</span></span><br><span class="line">    <span class="keyword">CMD</span><span class="bash"> [<span class="string">&quot;executable&quot;</span>,<span class="string">&quot;param1&quot;</span>,<span class="string">&quot;param2&quot;</span>] (执行可执行文件，优先)</span></span><br><span class="line">    <span class="keyword">CMD</span><span class="bash"> [<span class="string">&quot;param1&quot;</span>,<span class="string">&quot;param2&quot;</span>] (设置了ENTRYPOINT，则直接调用ENTRYPOINT添加参数)</span></span><br><span class="line">    <span class="keyword">CMD</span><span class="bash"> <span class="built_in">command</span> param1 param2 (执行shell内部命令)</span></span><br><span class="line"><span class="comment"># 示例：</span></span><br><span class="line">    <span class="keyword">CMD</span><span class="bash"> <span class="built_in">echo</span> <span class="string">&quot;This is a test.&quot;</span> | wc -</span></span><br><span class="line">    <span class="keyword">CMD</span><span class="bash"> [<span class="string">&quot;/usr/bin/wc&quot;</span>,<span class="string">&quot;--help&quot;</span>]</span></span><br><span class="line"><span class="comment"># 注：CMD不同于RUN，CMD用于指定在容器启动时所要执行的命令，而RUN用于指定镜像构建时所要执行的命令。</span></span><br></pre></td></tr></table></figure></li>
<li><h4 id="ENTRYPOINT：配置容器，使其可执行化。配合CMD可省去”application”，只使用参数"><a href="#ENTRYPOINT：配置容器，使其可执行化。配合CMD可省去”application”，只使用参数" class="headerlink" title="ENTRYPOINT：配置容器，使其可执行化。配合CMD可省去”application”，只使用参数"></a>ENTRYPOINT：配置容器，使其可执行化。配合CMD可省去”application”，只使用参数</h4><figure class="highlight docker"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#格式：</span></span><br><span class="line">    <span class="keyword">ENTRYPOINT</span><span class="bash"> [<span class="string">&quot;executable&quot;</span>, <span class="string">&quot;param1&quot;</span>, <span class="string">&quot;param2&quot;</span>] (可执行文件, 优先)</span></span><br><span class="line">    <span class="keyword">ENTRYPOINT</span><span class="bash"> <span class="built_in">command</span> param1 param2 (shell内部命令)</span></span><br><span class="line"><span class="comment">#示例：</span></span><br><span class="line">    <span class="keyword">FROM</span> ubuntu</span><br><span class="line">    <span class="keyword">ENTRYPOINT</span><span class="bash"> [<span class="string">&quot;top&quot;</span>, <span class="string">&quot;-b&quot;</span>]</span></span><br><span class="line">    <span class="keyword">CMD</span><span class="bash"> [<span class="string">&quot;-c&quot;</span>]</span></span><br><span class="line"><span class="comment">#注：ENTRYPOINT与CMD非常类似，不同的是通过docker run执行的命令不会覆盖ENTRYPOINT，而docker run命令中指定的任何参数，都会被当做参数再次传递给ENTRYPOINT。Dockerfile中只允许有一个ENTRYPOINT命令，多指定时会覆盖前面的设置，而只执行最后的ENTRYPOINT指令。</span></span><br></pre></td></tr></table></figure>
</li>
<li><h4 id="LABEL：用于为镜像添加元数据"><a href="#LABEL：用于为镜像添加元数据" class="headerlink" title="LABEL：用于为镜像添加元数据"></a>LABEL：用于为镜像添加元数据</h4><figure class="highlight docker"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#格式：</span></span><br><span class="line">    <span class="keyword">LABEL</span><span class="bash"> &lt;key&gt;=&lt;value&gt; &lt;key&gt;=&lt;value&gt; &lt;key&gt;=&lt;value&gt; ...</span></span><br><span class="line"><span class="comment">#示例：</span></span><br><span class="line">　　<span class="keyword">LABEL</span><span class="bash"> version=<span class="string">&quot;1.0&quot;</span> description=<span class="string">&quot;这是一个Web服务器&quot;</span> by=<span class="string">&quot;IT笔录&quot;</span></span></span><br><span class="line"><span class="comment">#注:使用LABEL指定元数据时，一条LABEL指定可以指定一或多条元数据，指定多条元数据时不同元数据之间通过空格分隔。推荐将所有的元数据通过一条LABEL指令指定，以免生成过多的中间镜像。</span></span><br></pre></td></tr></table></figure>
</li>
<li><h4 id="ENV：设置环境变量"><a href="#ENV：设置环境变量" class="headerlink" title="ENV：设置环境变量"></a>ENV：设置环境变量</h4><figure class="highlight docker"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#格式：</span></span><br><span class="line">    <span class="keyword">ENV</span> &lt;key&gt; &lt;value&gt;  <span class="comment">#&lt;key&gt;之后的所有内容均会被视为其&lt;value&gt;的组成部分，因此，一次只能设置一个变量</span></span><br><span class="line">    <span class="keyword">ENV</span> &lt;key&gt;=&lt;value&gt; ...  <span class="comment">#可以设置多个变量，每个变量为一个&quot;&lt;key&gt;=&lt;value&gt;&quot;的键值对，如果&lt;key&gt;中包含空格，可以使用\来进行转义，也可以通过&quot;&quot;来进行标示；另外，反斜线也可以用于续行</span></span><br><span class="line"><span class="comment"># 示例：</span></span><br><span class="line">    <span class="keyword">ENV</span> myName John Doe</span><br><span class="line">    <span class="keyword">ENV</span> myDog Rex The Dog</span><br><span class="line">    <span class="keyword">ENV</span> myCat=fluffy</span><br></pre></td></tr></table></figure></li>
<li><h4 id="EXPOSE：指定于外界交互的端口"><a href="#EXPOSE：指定于外界交互的端口" class="headerlink" title="EXPOSE：指定于外界交互的端口"></a>EXPOSE：指定于外界交互的端口</h4><figure class="highlight docker"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#格式：</span></span><br><span class="line">    <span class="keyword">EXPOSE</span> &lt;port&gt; [&lt;port&gt;...]</span><br><span class="line"><span class="comment">#示例：</span></span><br><span class="line">    <span class="keyword">EXPOSE</span> <span class="number">80</span> <span class="number">443</span></span><br><span class="line">    <span class="keyword">EXPOSE</span> <span class="number">8080</span></span><br><span class="line">    <span class="keyword">EXPOSE</span> <span class="number">11211</span>/tcp <span class="number">11211</span>/udp</span><br><span class="line"><span class="comment">#注:EXPOSE并不会让容器的端口访问到主机。要使其可访问，需要在docker run运行容器时通过-p来发布这些端口，或通过-P参数来发布EXPOSE导出的所有端口</span></span><br></pre></td></tr></table></figure></li>
<li><h4 id="VOLUME：用于指定持久化目录"><a href="#VOLUME：用于指定持久化目录" class="headerlink" title="VOLUME：用于指定持久化目录"></a>VOLUME：用于指定持久化目录</h4><figure class="highlight docker"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#格式：</span></span><br><span class="line">    <span class="keyword">VOLUME</span><span class="bash"> [<span class="string">&quot;/path/to/dir&quot;</span>]</span></span><br><span class="line"><span class="comment">#示例：</span></span><br><span class="line">    <span class="keyword">VOLUME</span><span class="bash"> [<span class="string">&quot;/data&quot;</span>]</span></span><br><span class="line">    <span class="keyword">VOLUME</span><span class="bash"> [<span class="string">&quot;/var/www&quot;</span>, <span class="string">&quot;/var/log/apache2&quot;</span>, <span class="string">&quot;/etc/apache2&quot;</span>]</span></span><br><span class="line"><span class="comment">#注:一个卷可以存在于一个或多个容器的指定目录，该目录可以绕过联合文件系统，并具有以下功能：</span></span><br><span class="line"><span class="comment"># 1 卷可以容器间共享和重用</span></span><br><span class="line"><span class="comment"># 2 容器并不一定要和其它容器共享卷</span></span><br><span class="line"><span class="comment"># 3 修改卷后会立即生效</span></span><br><span class="line"><span class="comment"># 4 对卷的修改不会对镜像产生影响</span></span><br><span class="line"><span class="comment"># 5 卷会一直存在，直到没有任何容器在使用它</span></span><br></pre></td></tr></table></figure>
</li>
<li><h4 id="WORKDIR：工作目录，类似于cd命令"><a href="#WORKDIR：工作目录，类似于cd命令" class="headerlink" title="WORKDIR：工作目录，类似于cd命令"></a>WORKDIR：工作目录，类似于cd命令</h4><figure class="highlight docker"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#格式：</span></span><br><span class="line">    <span class="keyword">WORKDIR</span><span class="bash"> /path/to/workdir</span></span><br><span class="line"><span class="comment">#示例：</span></span><br><span class="line">    <span class="keyword">WORKDIR</span><span class="bash"> /a  (这时工作目录为/a)</span></span><br><span class="line">    <span class="keyword">WORKDIR</span><span class="bash"> b  (这时工作目录为/a/b)</span></span><br><span class="line">    <span class="keyword">WORKDIR</span><span class="bash"> c  (这时工作目录为/a/b/c)</span></span><br><span class="line"><span class="comment">#注:通过WORKDIR设置工作目录后，Dockerfile中其后的命令RUN、CMD、ENTRYPOINT、ADD、COPY等命令都会在该目录下执行。在使用docker run运行容器时，可以通过-w参数覆盖构建时所设置的工</span></span><br></pre></td></tr></table></figure>
<h3 id="构建镜像"><a href="#构建镜像" class="headerlink" title="构建镜像"></a>构建镜像</h3><p>docker build [OPTIONS]上下文路径|URL</p>
</li>
<li><p>[OPTIONS]：通常指令包括-t，用来指定image的名字。-f指定Dockfile的上下文路径。</p>
</li>
<li><p>上下文路径|URL：上下文路径，如果只有一个小圆点 “.” 代表当前目录。    </p>
</li>
</ul>
<p>示例 构建一个名字为 <code>webtest</code> 的镜像</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker bulid -t  webtest .  </span><br></pre></td></tr></table></figure>
<h3 id="docker-compose"><a href="#docker-compose" class="headerlink" title="docker-compose"></a>docker-compose</h3><p>基本格式</p>
<figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">version:</span> <span class="string">&#x27;2&#x27;</span></span><br><span class="line"><span class="attr">services:</span></span><br><span class="line">  <span class="attr">web:</span></span><br><span class="line">    <span class="attr">image:</span> <span class="string">dockercloud/hello-world</span></span><br><span class="line">    <span class="attr">ports:</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">&quot;8080:8080&quot;</span></span><br><span class="line">    <span class="attr">networks:</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">front-tier</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">back-tier</span></span><br><span class="line">    <span class="attr">volumes:</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">my_volumes:/usr/local/bin</span></span><br><span class="line"></span><br><span class="line">  <span class="attr">redis:</span></span><br><span class="line">    <span class="attr">image:</span> <span class="string">redis</span></span><br><span class="line">    <span class="attr">links:</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">web</span></span><br><span class="line">    <span class="attr">networks:</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">back-tier</span></span><br><span class="line"></span><br><span class="line">  <span class="attr">lb:</span></span><br><span class="line">    <span class="attr">image:</span> <span class="string">dockercloud/haproxy</span></span><br><span class="line">    <span class="attr">ports:</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">&quot;80:80&quot;</span></span><br><span class="line">    <span class="attr">links:</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">web</span></span><br><span class="line">    <span class="attr">networks:</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">front-tier</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">back-tier</span></span><br><span class="line">    <span class="attr">volumes:</span> <span class="comment"># 宿主机与容器内目录共享</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">/var/run/docker.sock:/var/run/docker.sock</span> </span><br><span class="line"><span class="attr">volumes:</span> <span class="comment"># 声明上面创建的卷名</span></span><br><span class="line">  <span class="attr">my_volumes:</span></span><br><span class="line"><span class="attr">networks:</span></span><br><span class="line">  <span class="attr">front-tier:</span></span><br><span class="line">    <span class="attr">driver:</span> <span class="string">bridge</span></span><br><span class="line">  <span class="attr">back-tier:</span></span><br><span class="line"><span class="attr">driver:</span> <span class="string">bridge</span></span><br></pre></td></tr></table></figure>
<p>可以看到一份标准配置文件应该包含 <code>version</code>、<code>services</code>、<code>networks</code> 三大部分，其中最关键的就是 <code>services</code> 和 <code>networks</code> 两个部分，下面我们来看其书写规则。</p>
<h3 id="services"><a href="#services" class="headerlink" title="services"></a>services</h3><ul>
<li><h4 id="image"><a href="#image" class="headerlink" title="image"></a>image</h4><figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">services:</span></span><br><span class="line">  <span class="attr">web:</span></span><br><span class="line">    <span class="attr">image:</span> <span class="string">hello-world</span></span><br></pre></td></tr></table></figure>
<p>在 <code>services</code> 标签下的第二级标签是 web，这个名字是用户自己自定义，它就是服务名称。<br>image 则是指定服务的镜像名称或镜像 ID。如果镜像在本地不存在，Compose 将会尝试拉取这个镜像。</p>
</li>
<li><h4 id="container-name"><a href="#container-name" class="headerlink" title="container_name"></a>container_name</h4><p>相当于docker build 中的 –name</p>
</li>
</ul>
<ul>
<li><h4 id="depends-on"><a href="#depends-on" class="headerlink" title="depends_on"></a>depends_on</h4><p>在使用 Compose 时，最大的好处就是少打启动命令，但是一般项目容器启动的顺序是有要求的，如果直接从上到下启动容器，必然会因为容器依赖问题而启动失败。<br>例如在没启动数据库容器的时候启动了应用容器，这时候应用容器会因为找不到数据库而退出，为了避免这种情况我们需要加入一个标签，就是 depends_on，这个标签解决了容器的依赖、启动先后的问题。<br>例如下面容器会先启动 redis 和 db 两个服务，最后才启动 web 服务：</p>
<figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">version:</span> <span class="string">&#x27;2&#x27;</span></span><br><span class="line"><span class="attr">services:</span></span><br><span class="line">  <span class="attr">web:</span></span><br><span class="line">    <span class="attr">build:</span> <span class="string">.</span></span><br><span class="line">    <span class="attr">depends_on:</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">db</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">redis</span></span><br><span class="line">  <span class="attr">redis:</span></span><br><span class="line">    <span class="attr">image:</span> <span class="string">redis</span></span><br><span class="line">  <span class="attr">db:</span></span><br><span class="line">    <span class="attr">image:</span> <span class="string">postgres</span></span><br></pre></td></tr></table></figure></li>
<li><h4 id="links"><a href="#links" class="headerlink" title="links"></a>links</h4><p>还记得上面的depends_on吧，那个标签解决的是启动顺序问题，这个标签解决的是容器连接问题，与Docker client的–link一样效果，会连接到其它服务中的容器。<br>格式如下：</p>
<figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">links:</span></span><br><span class="line"> <span class="bullet">-</span> <span class="string">db</span></span><br><span class="line"> <span class="bullet">-</span> <span class="string">db:database</span></span><br><span class="line"> <span class="bullet">-</span> <span class="string">redis</span></span><br></pre></td></tr></table></figure>
<p>使用的别名将会自动在服务容器中的/etc/hosts里创建。例如：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">172.12.2.186  db</span><br><span class="line">172.12.2.186  database</span><br><span class="line">172.12.2.187  redis</span><br></pre></td></tr></table></figure>
<p>相应的环境变量也将被创建。</p>
</li>
<li><h4 id="environment"><a href="#environment" class="headerlink" title="environment"></a>environment</h4><p>这个标签的作用是设置镜像变量，它可以保存变量到镜像里面，也就是说启动的容器也会包含这些变量设置，这是与 arg 最大的不同。<br>一般 arg 标签的变量仅用在构建过程中。而 environment 和 Dockerfile 中的 ENV 指令一样会把变量一直保存在镜像、容器中，类似 docker run -e 的效果。</p>
</li>
</ul>
<figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">environment:</span></span><br><span class="line">  <span class="attr">RACK_ENV:</span> <span class="string">development</span></span><br><span class="line">  <span class="attr">SHOW:</span> <span class="string">&#x27;true&#x27;</span></span><br><span class="line">  <span class="attr">SESSION_SECRET:</span></span><br><span class="line"><span class="attr">environment:</span></span><br><span class="line">  <span class="bullet">-</span> <span class="string">RACK_ENV=development</span></span><br><span class="line">  <span class="bullet">-</span> <span class="string">SHOW=&#x27;true&#x27;</span></span><br><span class="line">  <span class="bullet">-</span> <span class="string">SESSION_SECRET=</span></span><br></pre></td></tr></table></figure>

<ul>
<li><h4 id="ports"><a href="#ports" class="headerlink" title="ports"></a>ports</h4><p>映射端口的标签。<br>使用HOST:CONTAINER格式或者只是指定容器的端口，宿主机会随机映射端口。</p>
<figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">ports:</span></span><br><span class="line"> <span class="bullet">-</span> <span class="string">&quot;3000&quot;</span></span><br><span class="line"> <span class="bullet">-</span> <span class="string">&quot;8000:8000&quot;</span></span><br><span class="line"> <span class="bullet">-</span> <span class="string">&quot;49100:22&quot;</span></span><br><span class="line"> <span class="bullet">-</span> <span class="string">&quot;127.0.0.1:8001:8001&quot;</span></span><br></pre></td></tr></table></figure>
<p>注意：当使用HOST:CONTAINER格式来映射端口时，如果你使用的容器端口小于60你可能会得到错误得结果，因为YAML将会解析xx:yy这种数字格式为60进制。所以建议采用字符串格式。</p>
</li>
<li><h4 id="networks"><a href="#networks" class="headerlink" title="networks"></a>networks</h4><p>加入指定网络，同一网络可以相互通讯，格式如下：</p>
<figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">services:</span></span><br><span class="line">  <span class="attr">some-service:</span></span><br><span class="line">    <span class="attr">networks:</span></span><br><span class="line">     <span class="bullet">-</span> <span class="string">some-network</span></span><br><span class="line">     <span class="bullet">-</span> <span class="string">other-network</span></span><br></pre></td></tr></table></figure>

</li>
</ul>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">兜里有糖</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://blog.cwxhmk.top/2021/05/08/program/2021-05-08-docker/">https://blog.cwxhmk.top/2021/05/08/program/2021-05-08-docker/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://blog.cwxhmk.top" target="_blank">兜里有糖</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E7%BC%96%E7%A8%8B/">编程</a></div><div class="post_share"><div class="social-share" data-image="https://image.cwxhmk.top/blog/docker.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/2020/08/24/program/2020-08-24-Linux常见命令/" title="Linux常见命令"><img class="cover" src= "/img/loading.gif" data-lazy-src="https://image.cwxhmk.top/blog/202008251.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-08-24</div><div class="title">Linux常见命令</div></div></a></div><div><a href="/2020/08/24/program/2020-08-24-Nginx安装与配置/" title="nginx安装与配置"><img class="cover" src= "/img/loading.gif" data-lazy-src="https://image.cwxhmk.top/blog/default_cover.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-08-24</div><div class="title">nginx安装与配置</div></div></a></div><div><a href="/2020/08/24/program/2020-08-24-Python-Install/" title="Python安装"><img class="cover" src= "/img/loading.gif" data-lazy-src="https://image.cwxhmk.top/blog/python.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-08-24</div><div class="title">Python安装</div></div></a></div><div><a href="/2020/08/24/program/2020-08-24-mongo/" title="Mongo"><img class="cover" src= "/img/loading.gif" data-lazy-src="https://image.cwxhmk.top/blog/default_cover.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-08-24</div><div class="title">Mongo</div></div></a></div><div><a href="/2020/08/24/program/2020-08-24-并发测试/" title="并发测试"><img class="cover" src= "/img/loading.gif" data-lazy-src="https://image.cwxhmk.top/blog/default_cover.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-08-24</div><div class="title">并发测试</div></div></a></div><div><a href="/2020/08/24/program/2020-08-24-部署/" title="部署"><img class="cover" src= "/img/loading.gif" data-lazy-src="https://image.cwxhmk.top/blog/gunicron.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-08-24</div><div class="title">部署</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="waline-wrap"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="card-info-avatar is-center"><img class="avatar-img" src= "/img/loading.gif" data-lazy-src="https://image.cwxhmk.top/blog/tou.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">兜里有糖</div><div class="author-info__description"></div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">14</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">11</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">1</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/dlytang"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/dlytang" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="/472548557" target="_blank" title="QQ"><i class="fab fa-qq"></i></a><a class="social-icon" href="mailto:472548557@qq.com" target="_blank" title="QQ"><i class="fab fa-envelope-o"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">欢迎</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85"><span class="toc-number">1.</span> <span class="toc-text">安装</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8D%B8%E8%BD%BD%E6%97%A7%E7%89%88%E6%9C%AC"><span class="toc-number">1.1.</span> <span class="toc-text">卸载旧版本</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85%E6%96%B0%E7%89%88%E6%9C%AC"><span class="toc-number">1.2.</span> <span class="toc-text">安装新版本</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Docker%E9%95%9C%E5%83%8F%E5%8A%A0%E9%80%9F"><span class="toc-number">1.3.</span> <span class="toc-text">Docker镜像加速</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%9B%B8%E5%85%B3%E5%91%BD%E4%BB%A4"><span class="toc-number">2.</span> <span class="toc-text">相关命令</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Dockerfile"><span class="toc-number">3.</span> <span class="toc-text">Dockerfile</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Dockerfile%E7%9A%84%E5%9F%BA%E6%9C%AC%E7%BB%93%E6%9E%84"><span class="toc-number">3.1.</span> <span class="toc-text">Dockerfile的基本结构</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%96%87%E4%BB%B6%E8%AF%B4%E6%98%8E"><span class="toc-number">3.2.</span> <span class="toc-text">文件说明</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#FROM%EF%BC%9A%E6%8C%87%E5%AE%9A%E5%9F%BA%E7%A1%80%E9%95%9C%E5%83%8F%EF%BC%8C%E5%BF%85%E9%A1%BB%E4%B8%BA%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%91%BD%E4%BB%A4"><span class="toc-number">3.2.1.</span> <span class="toc-text">FROM：指定基础镜像，必须为第一个命令</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#MAINTAINER-%E7%BB%B4%E6%8A%A4%E8%80%85%E4%BF%A1%E6%81%AF"><span class="toc-number">3.2.2.</span> <span class="toc-text">MAINTAINER: 维护者信息</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#RUN%EF%BC%9A%E6%9E%84%E5%BB%BA%E9%95%9C%E5%83%8F%E6%97%B6%E6%89%A7%E8%A1%8C%E7%9A%84%E5%91%BD%E4%BB%A4"><span class="toc-number">3.2.3.</span> <span class="toc-text">RUN：构建镜像时执行的命令</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#ADD%EF%BC%9A%E5%B0%86%E6%9C%AC%E5%9C%B0%E6%96%87%E4%BB%B6%E6%B7%BB%E5%8A%A0%E5%88%B0%E5%AE%B9%E5%99%A8%E4%B8%AD%EF%BC%8Ctar%E7%B1%BB%E5%9E%8B%E6%96%87%E4%BB%B6%E4%BC%9A%E8%87%AA%E5%8A%A8%E8%A7%A3%E5%8E%8B-%E7%BD%91%E7%BB%9C%E5%8E%8B%E7%BC%A9%E8%B5%84%E6%BA%90%E4%B8%8D%E4%BC%9A%E8%A2%AB%E8%A7%A3%E5%8E%8B-%EF%BC%8C%E5%8F%AF%E4%BB%A5%E8%AE%BF%E9%97%AE%E7%BD%91%E7%BB%9C%E8%B5%84%E6%BA%90%EF%BC%8C%E7%B1%BB%E4%BC%BCwget"><span class="toc-number">3.2.4.</span> <span class="toc-text">ADD：将本地文件添加到容器中，tar类型文件会自动解压(网络压缩资源不会被解压)，可以访问网络资源，类似wget</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#COPY%EF%BC%9A%E5%8A%9F%E8%83%BD%E7%B1%BB%E4%BC%BCADD%EF%BC%8C%E4%BD%86%E6%98%AF%E6%98%AF%E4%B8%8D%E4%BC%9A%E8%87%AA%E5%8A%A8%E8%A7%A3%E5%8E%8B%E6%96%87%E4%BB%B6%EF%BC%8C%E4%B9%9F%E4%B8%8D%E8%83%BD%E8%AE%BF%E9%97%AE%E7%BD%91%E7%BB%9C%E8%B5%84%E6%BA%90"><span class="toc-number">3.2.5.</span> <span class="toc-text">COPY：功能类似ADD，但是是不会自动解压文件，也不能访问网络资源</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#CMD%EF%BC%9A%E6%9E%84%E5%BB%BA%E5%AE%B9%E5%99%A8%E5%90%8E%E8%B0%83%E7%94%A8%EF%BC%8C%E4%B9%9F%E5%B0%B1%E6%98%AF%E5%9C%A8%E5%AE%B9%E5%99%A8%E5%90%AF%E5%8A%A8%E6%97%B6%E6%89%8D%E8%BF%9B%E8%A1%8C%E8%B0%83%E7%94%A8"><span class="toc-number">3.2.6.</span> <span class="toc-text">CMD：构建容器后调用，也就是在容器启动时才进行调用</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#ENTRYPOINT%EF%BC%9A%E9%85%8D%E7%BD%AE%E5%AE%B9%E5%99%A8%EF%BC%8C%E4%BD%BF%E5%85%B6%E5%8F%AF%E6%89%A7%E8%A1%8C%E5%8C%96%E3%80%82%E9%85%8D%E5%90%88CMD%E5%8F%AF%E7%9C%81%E5%8E%BB%E2%80%9Dapplication%E2%80%9D%EF%BC%8C%E5%8F%AA%E4%BD%BF%E7%94%A8%E5%8F%82%E6%95%B0"><span class="toc-number">3.2.7.</span> <span class="toc-text">ENTRYPOINT：配置容器，使其可执行化。配合CMD可省去”application”，只使用参数</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#LABEL%EF%BC%9A%E7%94%A8%E4%BA%8E%E4%B8%BA%E9%95%9C%E5%83%8F%E6%B7%BB%E5%8A%A0%E5%85%83%E6%95%B0%E6%8D%AE"><span class="toc-number">3.2.8.</span> <span class="toc-text">LABEL：用于为镜像添加元数据</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#ENV%EF%BC%9A%E8%AE%BE%E7%BD%AE%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F"><span class="toc-number">3.2.9.</span> <span class="toc-text">ENV：设置环境变量</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#EXPOSE%EF%BC%9A%E6%8C%87%E5%AE%9A%E4%BA%8E%E5%A4%96%E7%95%8C%E4%BA%A4%E4%BA%92%E7%9A%84%E7%AB%AF%E5%8F%A3"><span class="toc-number">3.2.10.</span> <span class="toc-text">EXPOSE：指定于外界交互的端口</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#VOLUME%EF%BC%9A%E7%94%A8%E4%BA%8E%E6%8C%87%E5%AE%9A%E6%8C%81%E4%B9%85%E5%8C%96%E7%9B%AE%E5%BD%95"><span class="toc-number">3.2.11.</span> <span class="toc-text">VOLUME：用于指定持久化目录</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#WORKDIR%EF%BC%9A%E5%B7%A5%E4%BD%9C%E7%9B%AE%E5%BD%95%EF%BC%8C%E7%B1%BB%E4%BC%BC%E4%BA%8Ecd%E5%91%BD%E4%BB%A4"><span class="toc-number">3.2.12.</span> <span class="toc-text">WORKDIR：工作目录，类似于cd命令</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9E%84%E5%BB%BA%E9%95%9C%E5%83%8F"><span class="toc-number">3.3.</span> <span class="toc-text">构建镜像</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#docker-compose"><span class="toc-number">3.4.</span> <span class="toc-text">docker-compose</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#services"><span class="toc-number">3.5.</span> <span class="toc-text">services</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#image"><span class="toc-number">3.5.1.</span> <span class="toc-text">image</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#container-name"><span class="toc-number">3.5.2.</span> <span class="toc-text">container_name</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#depends-on"><span class="toc-number">3.5.3.</span> <span class="toc-text">depends_on</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#links"><span class="toc-number">3.5.4.</span> <span class="toc-text">links</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#environment"><span class="toc-number">3.5.5.</span> <span class="toc-text">environment</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#ports"><span class="toc-number">3.5.6.</span> <span class="toc-text">ports</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#networks"><span class="toc-number">3.5.7.</span> <span class="toc-text">networks</span></a></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2021/08/22/program/2021-08-22-coding/" title="Coding"><img src= "/img/loading.gif" data-lazy-src="https://image.cwxhmk.top/blog/coding.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Coding"/></a><div class="content"><a class="title" href="/2021/08/22/program/2021-08-22-coding/" title="Coding">Coding</a><time datetime="2021-08-22T21:20:19.000Z" title="发表于 2021-08-22 21:20:19">2021-08-22</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/08/22/program/2021-08-22-linuxTowindows/" title="Linux Windows"><img src= "/img/loading.gif" data-lazy-src="https://image.cwxhmk.top/blog/linux_windows.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Linux Windows"/></a><div class="content"><a class="title" href="/2021/08/22/program/2021-08-22-linuxTowindows/" title="Linux Windows">Linux Windows</a><time datetime="2021-08-22T21:16:19.000Z" title="发表于 2021-08-22 21:16:19">2021-08-22</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/07/16/program/2021-07-16-wechaty/" title="Wechaty"><img src= "/img/loading.gif" data-lazy-src="https://image.cwxhmk.top/blog/wechaty.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Wechaty"/></a><div class="content"><a class="title" href="/2021/07/16/program/2021-07-16-wechaty/" title="Wechaty">Wechaty</a><time datetime="2021-07-16T21:16:19.000Z" title="发表于 2021-07-16 21:16:19">2021-07-16</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/05/15/program/2021-05-15-cloudreve/" title="个人网盘"><img src= "/img/loading.gif" data-lazy-src="https://image.cwxhmk.top/blog/cloudreve.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="个人网盘"/></a><div class="content"><a class="title" href="/2021/05/15/program/2021-05-15-cloudreve/" title="个人网盘">个人网盘</a><time datetime="2021-05-15T21:16:19.000Z" title="发表于 2021-05-15 21:16:19">2021-05-15</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/05/08/program/2021-05-08-docker/" title="docker"><img src= "/img/loading.gif" data-lazy-src="https://image.cwxhmk.top/blog/docker.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="docker"/></a><div class="content"><a class="title" href="/2021/05/08/program/2021-05-08-docker/" title="docker">docker</a><time datetime="2021-05-08T20:16:19.000Z" title="发表于 2021-05-08 20:16:19">2021-05-08</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('https://image.cwxhmk.top/blog/docker.jpg')"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2022 By 兜里有糖</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text"><a target="_blank" rel="noopener" href="https://www.upyun.com/?utm_source=lianmeng&utm_medium=referral">本站由<img src= "/img/loading.gif" data-lazy-src="/img/logo5.png" class="upyun"/> 提供CDN加速</a> <div href="https://beian.miit.gov.cn/#/Integrated/index"><img class="icp-icon" src= "/img/loading.gif" data-lazy-src="/img/icp.png"><span>备案号：陕ICP备20000393号</span></div></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="/js/search/local-search.js"></script><div class="js-pjax"><script>function loadWaline () {
  function initWaline () {
    const waline = new Waline(Object.assign({
      el: '#waline-wrap',
      serverURL: 'https://blog-weld-phi.vercel.app/',
      avatar: 'monsterid',
      path: location.pathname,
      emojiCDN: '//i0.hdslb.com/bfs/emote/',
      emojiMaps: {"tv_doge":"6ea59c827c414b4a2955fe79e0f6fd3dcd515e24.png","tv_亲亲":"a8111ad55953ef5e3be3327ef94eb4a39d535d06.png","tv_偷笑":"bb690d4107620f1c15cff29509db529a73aee261.png","tv_再见":"180129b8ea851044ce71caf55cc8ce44bd4a4fc8.png","tv_冷漠":"b9cbc755c2b3ee43be07ca13de84e5b699a3f101.png","tv_发怒":"34ba3cd204d5b05fec70ce08fa9fa0dd612409ff.png","tv_发财":"34db290afd2963723c6eb3c4560667db7253a21a.png","tv_可爱":"9e55fd9b500ac4b96613539f1ce2f9499e314ed9.png","tv_吐血":"09dd16a7aa59b77baa1155d47484409624470c77.png","tv_呆":"fe1179ebaa191569b0d31cecafe7a2cd1c951c9d.png","tv_呕吐":"9f996894a39e282ccf5e66856af49483f81870f3.png","tv_困":"241ee304e44c0af029adceb294399391e4737ef2.png","tv_坏笑":"1f0b87f731a671079842116e0991c91c2c88645a.png","tv_大佬":"093c1e2c490161aca397afc45573c877cdead616.png","tv_大哭":"23269aeb35f99daee28dda129676f6e9ea87934f.png","tv_委屈":"d04dba7b5465779e9755d2ab6f0a897b9b33bb77.png","tv_害羞":"a37683fb5642fa3ddfc7f4e5525fd13e42a2bdb1.png","tv_尴尬":"7cfa62dafc59798a3d3fb262d421eeeff166cfa4.png","tv_微笑":"70dc5c7b56f93eb61bddba11e28fb1d18fddcd4c.png","tv_思考":"90cf159733e558137ed20aa04d09964436f618a1.png","tv_惊吓":"0d15c7e2ee58e935adc6a7193ee042388adc22af.png"},
      visitor: false,
      dark: '[data-theme="dark"]'
    }, null))
  }

  if (typeof Waline === 'function') initWaline() 
  else getScript('https://cdn.jsdelivr.net/npm/@waline/client/dist/Waline.min.js').then(initWaline)
}

if ('Waline' === 'Waline' || !false) {
  if (false) btf.loadComment(document.getElementById('waline-wrap'),loadWaline)
  else setTimeout(loadWaline, 0)
} else {
  function loadOtherComment () {
    loadWaline()
  }
}</script></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/gh/metowolf/MetingJS@1.2/dist/Meting.min.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>